from settings import DOWN_DIR,ARIA2_HOST,ARIA2_PORT,RPC_SECRET
from aria2p import API
# from aria2p import Options
from aria2p import Client

'''连接aria2c
命令行运行 aria2c --enable-rpc --rpc-secret=this_for_alsit_pikpak
rpc-secret要与settints.py文件中一致
'''


# Client
aria2 = API(Client(
    host= 'http://' + ARIA2_HOST,
    port= ARIA2_PORT,
    secret= RPC_SECRET))

def pikpak_down(url,fname,dir=DOWN_DIR):
    aria2.add_uris(uris= [url], options={'out': fname,'dir': dir})

API(Client)

if __name__ == '__main__':
    pikpak_down(r'http://localhost:5244/d/all/%E7%AC%94%E8%AE%B0%E5%A4%87%E4%BB%BD/%E9%9F%B3/%E7%BE%9E%E7%AD%94%E7%AD%94%E7%9A%84%E7%8E%AB%E7%91%B0%E9%9D%99%E6%82%84%E6%82%84%E5%9C%B0%E5%BC%80(%E7%B2%A4%E8%AF%AD%E7%89%88)-%E5%A4%A7%E7%AC%A8.flac?sign=Fqn1I4RCQkEx-kSVHEe36MnJHSco7bO5Z0slHeqk8xI=:0', 
        '羞答答的玫瑰.flac')
